/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "prodorder", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"orderId"})})
@NamedQueries({@NamedQuery(name = "Prodorder.findAll", query = "SELECT p FROM Prodorder p"), @NamedQuery(name = "Prodorder.findByOrderId", query = "SELECT p FROM Prodorder p WHERE p.orderId = :orderId"), @NamedQuery(name = "Prodorder.findByPaymentStatus", query = "SELECT p FROM Prodorder p WHERE p.paymentStatus = :paymentStatus"), @NamedQuery(name = "Prodorder.findByShippingExpanses", query = "SELECT p FROM Prodorder p WHERE p.shippingExpanses = :shippingExpanses"), @NamedQuery(name = "Prodorder.findByOrderAmount", query = "SELECT p FROM Prodorder p WHERE p.orderAmount = :orderAmount"), @NamedQuery(name = "Prodorder.findByOrderAmountPaid", query = "SELECT p FROM Prodorder p WHERE p.orderAmountPaid = :orderAmountPaid"), @NamedQuery(name = "Prodorder.findByOrderAmountRemaini", query = "SELECT p FROM Prodorder p WHERE p.orderAmountRemaini = :orderAmountRemaini"), @NamedQuery(name = "Prodorder.findByOrderDueDate", query = "SELECT p FROM Prodorder p WHERE p.orderDueDate = :orderDueDate"), @NamedQuery(name = "Prodorder.findByOrderPlacingDate", query = "SELECT p FROM Prodorder p WHERE p.orderPlacingDate = :orderPlacingDate"), @NamedQuery(name = "Prodorder.findByOrderCompletedDate", query = "SELECT p FROM Prodorder p WHERE p.orderCompletedDate = :orderCompletedDate"), @NamedQuery(name = "Prodorder.findByOrderStatus", query = "SELECT p FROM Prodorder p WHERE p.orderStatus = :orderStatus"), @NamedQuery(name = "Prodorder.findByOrderType", query = "SELECT p FROM Prodorder p WHERE p.orderType = :orderType"), @NamedQuery(name = "Prodorder.findByItemCount", query = "SELECT p FROM Prodorder p WHERE p.itemCount = :itemCount")})
public class Prodorder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "orderId", nullable = false)
    private Integer orderId;
    @Basic(optional = false)
    @Column(name = "paymentStatus", nullable = false, length = 10)
    private String paymentStatus;
    @Basic(optional = false)
    @Column(name = "shippingExpanses", nullable = false)
    private float shippingExpanses;
    @Basic(optional = false)
    @Column(name = "orderAmount", nullable = false)
    private float orderAmount;
    @Basic(optional = false)
    @Column(name = "orderAmountPaid", nullable = false)
    private float orderAmountPaid;
    @Basic(optional = false)
    @Column(name = "orderAmountRemaini", nullable = false)
    private float orderAmountRemaini;
    @Basic(optional = false)
    @Column(name = "orderDueDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderDueDate;
    @Column(name = "orderPlacingDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderPlacingDate;
    @Column(name = "orderCompletedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date orderCompletedDate;
    @Column(name = "orderStatus", length = 10)
    private String orderStatus;
    @Column(name = "orderType", length = 10)
    private String orderType;
    @Column(name = "itemCount")
    private Integer itemCount;
    @OneToMany(mappedBy = "orderId")
    private Collection<Stock> stockCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "prodorder")
    private Collection<Orderlineitem> orderlineitemCollection;
    @JoinColumn(name = "userId", referencedColumnName = "userId")
    @ManyToOne
    private Systemuser userId;
    @JoinColumn(name = "customerId", referencedColumnName = "customerId")
    @ManyToOne
    private Customer customerId;
    @JoinColumn(name = "supplierId", referencedColumnName = "supplierId")
    @ManyToOne
    private Supplier supplierId;

    public Prodorder() {
    }

    public Prodorder(Integer orderId) {
        this.orderId = orderId;
    }

    public Prodorder(Integer orderId, String paymentStatus, float shippingExpanses, float orderAmount, float orderAmountPaid, float orderAmountRemaini, Date orderDueDate) {
        this.orderId = orderId;
        this.paymentStatus = paymentStatus;
        this.shippingExpanses = shippingExpanses;
        this.orderAmount = orderAmount;
        this.orderAmountPaid = orderAmountPaid;
        this.orderAmountRemaini = orderAmountRemaini;
        this.orderDueDate = orderDueDate;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public String getPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(String paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    public float getShippingExpanses() {
        return shippingExpanses;
    }

    public void setShippingExpanses(float shippingExpanses) {
        this.shippingExpanses = shippingExpanses;
    }

    public float getOrderAmount() {
        return orderAmount;
    }

    public void setOrderAmount(float orderAmount) {
        this.orderAmount = orderAmount;
    }

    public float getOrderAmountPaid() {
        return orderAmountPaid;
    }

    public void setOrderAmountPaid(float orderAmountPaid) {
        this.orderAmountPaid = orderAmountPaid;
    }

    public float getOrderAmountRemaini() {
        return orderAmountRemaini;
    }

    public void setOrderAmountRemaini(float orderAmountRemaini) {
        this.orderAmountRemaini = orderAmountRemaini;
    }

    public Date getOrderDueDate() {
        return orderDueDate;
    }

    public void setOrderDueDate(Date orderDueDate) {
        this.orderDueDate = orderDueDate;
    }

    public Date getOrderPlacingDate() {
        return orderPlacingDate;
    }

    public void setOrderPlacingDate(Date orderPlacingDate) {
        this.orderPlacingDate = orderPlacingDate;
    }

    public Date getOrderCompletedDate() {
        return orderCompletedDate;
    }

    public void setOrderCompletedDate(Date orderCompletedDate) {
        this.orderCompletedDate = orderCompletedDate;
    }

    public String getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(String orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getOrderType() {
        return orderType;
    }

    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }

    public Integer getItemCount() {
        return itemCount;
    }

    public void setItemCount(Integer itemCount) {
        this.itemCount = itemCount;
    }

    public Collection<Stock> getStockCollection() {
        return stockCollection;
    }

    public void setStockCollection(Collection<Stock> stockCollection) {
        this.stockCollection = stockCollection;
    }

    public Collection<Orderlineitem> getOrderlineitemCollection() {
        return orderlineitemCollection;
    }

    public void setOrderlineitemCollection(Collection<Orderlineitem> orderlineitemCollection) {
        this.orderlineitemCollection = orderlineitemCollection;
    }

    public Systemuser getUserId() {
        return userId;
    }

    public void setUserId(Systemuser userId) {
        this.userId = userId;
    }

    public Customer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Customer customerId) {
        this.customerId = customerId;
    }

    public Supplier getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Supplier supplierId) {
        this.supplierId = supplierId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orderId != null ? orderId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Prodorder)) {
            return false;
        }
        Prodorder other = (Prodorder) object;
        if ((this.orderId == null && other.orderId != null) || (this.orderId != null && !this.orderId.equals(other.orderId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Prodorder[orderId=" + orderId + "]";
    }

}
